package cn.liyicun.cp.cpweb.component.freemark;


import freemarker.template.Configuration;
import freemarker.template.TemplateModelException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class FreemarkerConfig {

    @Autowired
    private Configuration configuration;
    @Autowired
    private UserNameMethodModel userNameMethodModel;
    @Autowired
    private MoneyMethodModel moneyMethodModel;

    @PostConstruct
    public void setSharedVariable() throws TemplateModelException {
        configuration.setSharedVariable("getUserName",userNameMethodModel);
        configuration.setSharedVariable("money",moneyMethodModel);

    }
}


